package com.pickgliss.ui.controls.container
{
	import com.pickgliss.instance.IManualSize;
	import com.pickgliss.ui.core.Component;
	
	import flash.display.DisplayObject;
	import flash.events.Event;
	import flash.filters.DropShadowFilter;

	/**
	 * 
	 * @author Herman
	 * 横行排列的容器对象
	 */	
	public class HBox extends BoxContainer
	{

		public function HBox()
		{
			super();
		}
		
		override protected function arrange():void
		{
			_width = 0;
			_height = 0;
			var xpos:Number = 0;
			for(var i:int = 0; i < _childrenList.length; i++)
			{
				var child:DisplayObject = _childrenList[i];
				var childWidth:Number = getItemWidth(child);
				var childHeight:Number = getItemHeight(child);
				child.x = xpos;
				xpos += childWidth;
				xpos += _spacing;
				_width += childWidth;
				_height = Math.max(_height,childHeight);
			}
			_width += _spacing * (numChildren - 1);
			_width = Math.max(0,_width);
			dispatchEvent(new Event(Event.RESIZE));
		}
		private function getItemHeight(child:DisplayObject):Number
		{
			if(child is Component)return (child as Component).displayHeight;
			return child.height;
		}
		private function getItemWidth(child:DisplayObject):Number
		{
			if(isStrictWidth)return _strictWidth;
			if(child is IManualSize)return (child as IManualSize).viewRectangle.width;
			if(child is Component)return (child as Component).displayWidth;
			return child.width;
		}
	}
}